$(function () {
    //实现用户登录
    $('.input_sub').on('click', function () {
        //1.获取用户数据
        let username = $('.input_txt').val()
        let password = $('.input_pass').val()
        console.log(username
            , password)
        // 2.先查阅接口文档
        //3.发起ajax请求
        $.ajax({
            type: 'post',
            // url: 'http://localhost:8080/api/v1/admin/user/login',
            url: bignews.user_login,
            data: { username, password },
            success: function (res) {
                console.log(res)
                //为模态设置消息内容,标签之间文本内容
                $('.modal-body > p').text(res.msg)
                //4.对响应数据进行处理
                if (res.code === 200) {
                    localStorage.setItem('bignews_69_token', res.token)
                    $('#tipModal').modal('show')
                    alert(res.msg)
                    //添加模态框隐藏的监听事件,在事件触发之后再进行跳转

                    $('#tipModal').on('hidden.bs.modal', function (e) {

                        //跳转

                        location.href = './index.html'

                    })

                } else {
                    $('#tipModal').modal('show')
                }
            }
        })
    })
    //单击模态框的确定,隐藏模态框 
    $('.btnConfirm').on('click', function () {
        $('#tipModal').modal('hide')
    })
})